package com.example.demo.base.login.dto;

import org.apache.commons.codec.binary.Base64;

import java.io.Serializable;
import java.security.interfaces.RSAPublicKey;

/**
 * TODO
 *
 * @author mazh47622
 * @date2023/12/18
 * @modify -----------------------------------------------------------------------------------------------------
 * |修改单号|修改人员|修改日期|评审人员|修改说明
 * -----------------------------------------------------------------------------------------------------
 * |      |       |      |       |
 * -----------------------------------------------------------------------------------------------------
 */
public class RsaPublicKeyBo implements Serializable {
    private static final long serialVersionUID = 1110954441225034643L;

    /** 公钥 **/
    private String modulus;

    /** 指数 **/
    private String exponent;

    /** 公钥字符串 **/
    private String publicKeyStr;

    /** 保存的随机数 **/
    private String random;

    public RsaPublicKeyBo(RSAPublicKey publicKey, String random, String publicKeyStr) {
        this.modulus = Base64.encodeBase64String(publicKey.getModulus().toByteArray());
        this.exponent = Base64.encodeBase64String(publicKey.getPublicExponent().toByteArray());
        this.random = random;
        this.publicKeyStr = publicKeyStr;
    }

    public String getModulus() {
        return modulus;
    }

    public void setModulus(String modulus) {
        this.modulus = modulus;
    }

    public String getExponent() {
        return exponent;
    }

    public void setExponent(String exponent) {
        this.exponent = exponent;
    }

    public String getPublicKeyStr() {
        return publicKeyStr;
    }

    public void setPublicKeyStr(String publicKeyStr) {
        this.publicKeyStr = publicKeyStr;
    }

    public String getRandom() {
        return random;
    }

    public void setRandom(String random) {
        this.random = random;
    }
}
